﻿using System.Collections.Generic;
using System.Reflection;
using DataGeneration.Domain.Helpers;

namespace DataGeneration.Domain.CustomProcessors
{
    /// <summary>
    /// Defines the type HumanNameGenerator
    /// </summary>
    public class HumanNameGenerator
    {
        private static IList<string> _humanNames;
        private static IList<string> _languages;

        private static readonly IList<string> Titles = new List<string>
                                                   {
                                                       "Mr",
                                                       "Ms",
                                                       "Mrs",
                                                       "Miss",
                                                       "Dr",
                                                       "Master",
                                                       "Chief",
                                                       "Sir",
                                                       "Dame",
                                                       "Lady"
                                                   };
        private static readonly IList<string> Gender = new List<string> { "Male", "Female" };
        private static readonly IList<string> ShortGender = new List<string> { "M", "F" };

        /// <summary>
        /// Gets the language.
        /// </summary>
        /// <value>The language.</value>
        public static string Language
        {
            get
            {
                if (_languages == null)
                {
                    _languages = FileHelper.ReadUniqueFileContent(Assembly.GetExecutingAssembly()
                                                                         .GetManifestResourceStream("DataGeneration.Domain.Resources.languages.txt"));
                }

                return _languages[RandomMizer.GetNextValue(0, _languages.Count - 1)];
            }
        }

        /// <summary>
        /// Gets the language code.
        /// </summary>
        /// <value>The language code.</value>
        public static string LanguageCode
        {
            get
            {
                if (_languages == null)
                {
                    _languages = FileHelper.ReadUniqueFileContent(Assembly.GetExecutingAssembly()
                                                                         .GetManifestResourceStream("DataGeneration.Domain.Resources.languages.txt"));
                }

                return _languages[RandomMizer.GetNextValue(0, _languages.Count - 1)].Substring(0,3);
            }
        }


        /// <summary>
        /// Gets the name of the human.
        /// </summary>
        /// <value>The name of the human.</value>
        public static string HumanName
        {
            get
            {
                if (_humanNames == null)
                {
                    _humanNames = FileHelper.ReadUniqueFileContent(Assembly.GetExecutingAssembly()
                                                                       .GetManifestResourceStream("DataGeneration.Domain.Resources.names.txt"));
                }
                
                return _humanNames[RandomMizer.GetNextValue(0, _humanNames.Count - 1)];
            }
        }
        /// <summary>
        /// Gets the human title.
        /// </summary>
        /// <value>The human title.</value>
        public static string HumanTitle
        {
            get
            {
                return Titles[RandomMizer.GetNextValue(0, Titles.Count - 1)];
            }
        }

        /// <summary>
        /// Gets the abbrevated human gender.
        /// </summary>
        /// <value>The abbrevated human gender.</value>
        public static string AbbrevatedHumanGender
        {
            get
            {
                return ShortGender[RandomMizer.GetNextValue(0, ShortGender.Count - 1)];
            }
        }
        /// <summary>
        /// Gets the human gender.
        /// </summary>
        /// <value>The human gender.</value>
        public static string HumanGender
        {
            get
            {
                return Gender[RandomMizer.GetNextValue(0, Gender.Count - 1)];
            }
        }
    
    }
}


